<template>
  <div class="main">
    <div class="tree-menu">
    <ul v-for="menuItem in theModel">
        <my-tree :model="menuItem"></my-tree>
      </ul>
    </div>

  </div>

</template>

<script>
  import myTree from './treemenu'
  import {companyList3} from '@/api/api'
  import {XHeader, Tabbar, TabbarItem, Group, Cell} from 'vux'

  export default {
    name: 'App',
    data () {
      return {
        sourceType: '',
        theModel: []
      }
    },
    components: {
      Tabbar,
      TabbarItem,
      Group,
      Cell,
      XHeader,
      myTree
    },
    created () {
      let userInfo = JSON.parse(localStorage.getItem('userInfo'))
      this.sourceType = this.$route.query.sourceType
      this.getCompany(userInfo.deptid, this.sourceType)
    },
    methods: {
      getCompany (departId, sourceType) {
        let param = {
          data: {
            deptId: departId,
            type: '0'
          }
        }
        companyList3(param).then(
          (res) => {
            console.log(res.data[0])
            this.theModel = res.data
            this.theModel[0].sourceType = this.sourceType
          }
        )
      }
    }
  }
</script>

<style scoped lang="less">

</style>
